<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>移动事件</title>
  <style>
    .wrapper {
      width: 100px;
      height: 100px;
      margin: 100px auto;
      text-align: center;
      line-height: 100px;
      color: #f0f;
      font-size: 20px;
    }
  </style>
</head>
<body>
  <div class="wrapper">

  </div>
  <script>
    var count = 0
    function mouseAction() {
      wrapper.innerHTML = count++
    }
    var wrapper = document.querySelector('.wrapper')
    wrapper.onmousemove = throttle(mouseAction, 1000)
    function throttle(fn, wait) {
      var _this, arg
      var prev = 0 // 上次触发时间，默认为0
      return function() {
        var now =+new Date()
        _this = this
        // console.log(_this)
        if(now - prev > wait) {
          fn.apply(_this, arg)
          prev = now
        }
       
      }
    }
  </script>
</body>
</html>